package com.sqz.controller;

import com.sqz.pojo.AdminsEntity;
import com.sqz.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/admin")
public class AdminController {

    @Autowired
    private AdminService adminService;


    @RequestMapping("/login")
    public String adminLogin(AdminsEntity adminsEntity, ModelMap module, HttpSession session) {

        AdminsEntity entity = adminService.adminLogin(adminsEntity);
        

        if (entity == null) {
            return "redirect:../login";
        } else {
            session.setAttribute("admin", entity);
            return "redirect:../index";
        }
    }


}
